package com.jvm.memory;
/**
 * 常量池
 *
 * @author Lizhong
 * @date 2019/2/20
 */
public class ConstantPool {
    public static void main(String[] args) {
        //有点东西
        String s1 =new StringBuilder("j").append("v").toString(); // 返回的常量池的实例子引用 j v
        System.out.println(s1==s1.intern()); //true

         String s2 =new StringBuilder("ja").append("va").toString(); //常量池没有 ja va的引用
        System.out.println(s2==s2.intern()); //true
          String s3 =new StringBuilder("jv").append("v").toString(); //常量池有 jv v的引用
        System.out.println(s3==s3.intern()); //true
    }
}
